<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-info">
            <form id="operlog-form">
                <div class="select-list gd">
                    <ul>
                        <li>
                            角色名称：<input type="text" name="roleName"/>
                        </li>
                        <li>
                            角色状态：
                            <select name="status">
                                <option value="0">所有</option>
                                <option value="0">正常</option>
                                <option value="1">停用</option>
                            </select>
                        </li>
                        <li class="select-time">
                            <label>创建时间： </label>
                            <input type="text" class="time-input" style="width: 150px" id="beginTime" placeholder="开始时间" name="beginTime" lay-key="1">
                            <span>-</span>
                            <input type="text" class="time-input" style="width: 150px" id="overTime" placeholder="结束时间" name="overTime" lay-key="2">
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm"
                               onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm"
                               onclick="$.form.reset($('form').attr('id'))"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group hidden-xs" id="toolbar" role="group">
            <a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.add()" shiro:hasPermission="role:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-outline btn-danger btn-rounded" onclick="$.operate.batRemove()"
               shiro:hasPermission="role:del">
                <i class="fa fa-trash-o"></i> 删除
            </a>
        </div>

        <div class="col-sm-12 select-info order-table">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = "/role";
    var updateFlag = [[${@permission.hasPermi('role:update')}]];
    var delFlag = [[${@permission.hasPermi('role:del')}]];
    $(function () {
        var options = {
            url: prefix + "/tableList",
            createUrl: prefix + "/toAdd",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/del",
            sortName: "roleId",
            modalName: "角色",
            search: false,
            showExport: false,
            columns: [{
                checkbox: true
            },
                {
                    field: 'roleId',
                    title: '角色编号',
                    visible:false
                },
                {
                    field: 'roleName',
                    title: '角色名称'
                },
                {
                    field: 'descr',
                    title: '角色备注'
                },
                {
                    field: 'status',
                    title: '状态',
                    align: 'center',
                    formatter: function (value, row, index) {
                        if (value == 0) {
                            return '<span class="badge badge-primary">正常</span>';
                        } else if (value == 1) {
                            return '<span class="badge badge-danger">停用</span>';
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    formatter: function (value) {
                        return $.common.dateFormat(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs '+updateFlag+'" href="#" onclick="$.operate.edit(\'' + row.roleId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-warning btn-xs '+updateFlag+'"  href="#" onclick="editPower(\'' + row.roleId + '\')"><i class="fa fa-expeditedssl"></i>权限</a> ');
                        actions.push('<a class="btn btn-danger btn-xs '+delFlag+'"  href="#" onclick="$.operate.remove(\'' + row.roleId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    //编辑修改权限
    function editPower(id){
        $.modal.open("修改" + $.table._option.modalName, prefix+"/editPower/"+id);
    }
</script>
</body>
</html>